import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutterjc/plugin/sqlite/constant/SQLiteConfigConstant.dart';
import 'package:flutterjc/plugin/sqlite/method/SQLiteDBMethod.dart';

void main() {
  runApp(new SqlitePlugin());
}

/*
 * 表单组件 <br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
class SqlitePlugin extends StatefulWidget {
  State<StatefulWidget> createState() {
    return new SqlitePluginState();
  }
}

/*
 * 页面功能 <br/>
 */
class SqlitePluginState extends State<StatefulWidget> {
  void initState() {
    super.initState();
    initDB();
  }

  /*
   * 初始化数据库
   */
  void initDB() {
    SQLiteConfigConstant.DATABASE_SQL_PATH.add("assets/sql/create_table.sql");
    SQLiteConfigConstant.DATABASE_SQL_PATH.add("assets/sql/zbcx.sql");
    SQLiteDBMethod.getInstance();
  }

  Widget build(BuildContext context) {
    AppBar appBar = AppBar(
      leading: new IconButton(
        icon: new Icon(Icons.arrow_back),
        onPressed: () {},
      ),
      title: new Text('FlutterDesign'),
      centerTitle: true,
      actions: <Widget>[
        new Container(width: 0, height: 0),
        new Container(width: 0, height: 0),
      ],
      backgroundColor: Colors.blue,
    );

    return MaterialApp(
      home: new Scaffold(
        appBar: appBar,
        body: new Builder(builder: (BuildContext context) {
          return Column(
            children: <Widget>[
              RaisedButton(
                child: Text('查询'),
                onPressed: () {
                  SQLiteDBMethod.getInstance()
                      .queryForAll('procs')
                      .then((value) => print(value));
                },
              )
            ],
          );
        }),
        backgroundColor: Colors.white,
        bottomNavigationBar: null,
      ),
    );
  }
}
